<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title><?php echo $message;?></title>
    <link rel="stylesheet"href="statics/mobile/plugins/weui/weui.min.css"/>
</head>
<body>
<div class="container" id="container">
  <div class="weui-msg">
        <div class="weui-msg__icon-area" id="icon"><i class="weui-icon-success weui-icon_msg"></i></div>
        <div class="weui-msg__text-area">
            <h2 class="weui-msg__title">操作提示</h2>
            <p class="weui-msg__desc" id="pay_status">正在查询状态</p>
        </div>
        <div class="weui-msg__extra-area">
            <div class="weui-footer">
                <p class="weui-footer__links">
                    <a href="javascript:void(0);" class="weui-footer__link">必得CMS bidcms.com</a>
                </p>
                <p class="weui-footer__text">Copyright © 2008-2016 bidcms.com</p>
            </div>
        </div>
    </div>
</div>
<?php if(!empty($result) && $result['code']==1){?>
<script type="text/javascript">
	var id="<?php echo $info['id'];?>";
    var ApiParam=<?php echo $jsApiParameters; ?>;
	//调用微信JS api 支付
	function jsApiCall()
	{
		document.getElementById("icon").innerHTML='<i class="weui-icon-success weui-icon_msg"></i>';
		document.getElementById("pay_status").innerHTML="正在调起微信支付";
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',ApiParam.data,
			function(res){
				WeixinJSBridge.log(res.err_msg);
				if(res.err_msg=='get_brand_wcpay_request:ok'){
					alert('支付成功');
					window.location.replace("?con=order&act=detail&id="+id);
				} else {
					document.getElementById("icon").innerHTML='<i class="weui-icon-warn weui-icon_msg"></i>';
					var error=res.err_desc==undefined?'取消支付':res.err_desc
					document.getElementById("pay_status").innerHTML=error;
				}
				
			}
		);
	}
  function callpay()
	{
		if (typeof WeixinJSBridge == "undefined"){
			if( document.addEventListener ){
				document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
			}else if (document.attachEvent){
				document.attachEvent('WeixinJSBridgeReady', jsApiCall);
				document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
			}
		}else{
			jsApiCall();
		}
	}
	callpay();
</script>

<?php } else {?>
<script>
  document.getElementById("icon").innerHTML='<i class="weui-icon-warn weui-icon_msg"></i>';
  document.getElementById("pay_status").innerHTML="<?php echo $result['msg'];?>";
</script>
<?php }?>
</body>
</html>
